﻿<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2007/rif#">
  <payload>
    <Group>
      <sentence>
        <Group>
          <behavior>
            <Priority>1</Priority>
          </behavior>
          <sentence>
            <Forall>
              <declare>
                <Var>x</Var>
              </declare>
              <formula>
                <Implies>
                  <if>
                    <Member>
                      <instance>
                        <Var>x</Var>
                      </instance>
                      <class>
                        <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#T</Const>
                      </class>
                    </Member>
                  </if>
                  <then>
                    <Do>
                      <actions ordered="yes">
                        <Retract>
                          <target ordered="yes">
                            <Frame>
                              <object>
                                <Var>x</Var>
                              </object>
                              <slot ordered="yes">
                                <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#p</Const>
                                <Const type="http://www.w3.org/2001/XMLSchema#int">1</Const>
                              </slot>
                            </Frame>
                          </target>
                        </Retract>
                      </actions>
                    </Do>
                  </then>
                </Implies>
              </formula>
            </Forall>
          </sentence>
        </Group>
      </sentence>
      <sentence>
        <Group>
          <behavior>
            <Priority>2</Priority>
          </behavior>
          <sentence>
            <Forall>
              <declare>
                <Var>y</Var>
              </declare>
              <formula>
                <Implies>
                  <if>
                    <And>
                      <formula>
                        <Member>
                          <instance>
                            <Var>y</Var>
                          </instance>
                          <class>
                            <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#T</Const>
                          </class>
                        </Member>
                      </formula>
                      <formula>
                        <Frame>
                          <object>
                            <Var>y</Var>
                          </object>
                          <slot ordered="yes">
                            <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#p</Const>
                            <Const type="http://www.w3.org/2001/XMLSchema#int">1</Const>
                          </slot>
                        </Frame>
                      </formula>
                    </And>
                  </if>
                  <then>
                    <Frame>
                      <object>
                        <Var>y</Var>
                      </object>
                      <slot ordered="yes">
                        <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#q</Const>
                        <Const type="http://www.w3.org/2001/XMLSchema#int">2</Const>
                      </slot>
                    </Frame>
                  </then>
                </Implies>
              </formula>
            </Forall>
          </sentence>
        </Group>
      </sentence>
      <sentence>
        <Do>
          <actionVar ordered="yes">
            <Var>new</Var>
            <New />
          </actionVar>
          <actions ordered="yes">
            <Assert>
              <target>
                <Member>
                  <instance>
                    <Var>new</Var>
                  </instance>
                  <class>
                    <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#T</Const>
                  </class>
                </Member>
              </target>
            </Assert>
            <Assert>
              <target>
                <Frame>
                  <object>
                    <Var>new</Var>
                  </object>
                  <slot ordered="yes">
                    <Const type="http://www.w3.org/2007/rif#iri">http://example.org/example#p</Const>
                    <Const type="http://www.w3.org/2001/XMLSchema#int">1</Const>
                  </slot>
                </Frame>
              </target>
            </Assert>
          </actions>
        </Do>
      </sentence>
    </Group>
  </payload>
</Document>